import urlFormat from './filter.js'

export default {
	data () {
		return {
			
		}
	},
	computed: {
		
	},
	watch: {
		
	},
	methods: {
		auth(url,auth=0){
			if(this.$store.getters.login){ // 登录 功能是否开放
				if(auth==-1){
					return uni.showToast({
						title:'功能未开放',
						icon:'none',
						duration:1500
					})
				}
				return uni.reLaunch({
					url
				});
			}else{ // 未登录
				uni.showModal({
					title: "温馨提示",
					content:"去登陆",
					showCancel: true,
					// confirmText:"登录",
					// cancelText:"取消",
					success: res=> {
						// 页面跳转（上一页）
						console.log(res);
						if(res.confirm){
							return uni.navigateTo({
								url:"/pages/my/auth"
							})	
						}else{
							return uni.hideLoading();
						}
					}
				})
			}
		},
		navTo(url){
			uni.navigateTo({
				url
			})
		},
		redTo(url){
			uni.redirectTo({
				url
			})
		},
		swiTo(url){
			uni.switchTab({
				url
			})
		},
		previewImg(url){
			console.log(url);return false;
			// url = urlFormat(url)
			uni.previewImage({
				urls:[url],
				indicator:'none',
			})
		}
	}
}